Imports DevExpress.XtraEditors
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Nodes
Imports DevExpress.XtraBars
'--- Created Date On : 12-Oct-2010 (Priyabrat)

Public Class frmSelectReport

    Private SelectedNode As TreeListNode

    Private Sub frmSelectReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            lstReports.BeginUpdate()
            lstReports.Columns.Add()
            lstReports.Columns(0).Caption = "Reports"
            lstReports.Columns(0).VisibleIndex = 0
            lstReports.EndUpdate()

            mdiMain.GetReportNode(lstReports)
            lstReports.ExpandAll()

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Call AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                 Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub lstReports_NodeCellStyle(ByVal sender As System.Object, ByVal e As DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs) Handles lstReports.NodeCellStyle
        If e.Node.Level = 1 Then
            e.Appearance.Font = New System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold)
        End If
    End Sub

    Private Sub lstReports_AfterFocusNode(ByVal sender As System.Object, ByVal e As DevExpress.XtraTreeList.NodeEventArgs) Handles lstReports.AfterFocusNode
        If e.Node.HasChildren = True Then
            btnOpen.Enabled = False
        Else
            btnOpen.Enabled = (True)
            SelectedNode = e.Node
        End If
    End Sub

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Dim MenuObject As BarButtonItem = CType(SelectedNode.Tag, BarButtonItem)

        CType(Me.ParentForm, mdiMain).bmWebPlusMed.Items(MenuObject.Name).PerformClick()

    End Sub

    Private Sub lstReports_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstReports.DoubleClick
        If btnOpen.Enabled = False Then Exit Sub
        Dim MenuObject As BarButtonItem = CType(SelectedNode.Tag, BarButtonItem)

        CType(Me.ParentForm, mdiMain).bmWebPlusMed.Items(MenuObject.Name).PerformClick()

    End Sub
End Class
